#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 3e5 + 5;

mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int n, m;
int a[N];
int mx[N << 2], tag[N << 2];
void pushup(int p) { mx[p] = max(mx[p << 1], mx[p << 1 | 1]); }
void addtag(int d, int p) { mx[p] += d, tag[p] += d; }
void pushdown(int p) {
  if (tag[p]) {
    addtag(tag[p], p << 1);
    addtag(tag[p], p << 1 | 1);
    tag[p] = 0;
  }
}
void build(int p, int l, int r) {
  mx[p] = tag[p] = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
void update(int L, int R, int d, int p, int l, int r) {
  if (L <= l && R >= r) {
    addtag(d, p);
    return;
  }
  pushdown(p);
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, d, p << 1, l, mid);
  if (R > mid) update(L, R, d, p << 1 | 1, mid + 1, r);
  pushup(p);
}
void update(int x, int v, int p, int l, int r) {
  if (l == r) {
    mx[p] = v;
    tag[p] = 0;
    return;
  }
  pushdown(p);
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(x, v, p << 1, l, mid);
  else
    update(x, v, p << 1 | 1, mid + 1, r);
  pushup(p);
}
void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  build(1, 0, n);
  rep(i, 1, n) {
    if (a[i] >= 1) update(0, a[i] - 1, 1, 1, 0, n);
    update(a[i], 0, 1, 0, n);
    cout << mx[1] << ' ';
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}